<template>
	<vi-popup ref="popup"
		:point="setting.point"
		:width="setting.width"
		:maxWidth="setting.maxWidth"
		:height="setting.height"
		:bgColor="setting.bgColor"
		:shift="shift"
		:radius="setting.radius"
		@maskClick="onMaskClick"
		@opened="onOpened"
		@closed="onClosed"
		@change="onChange">
		<view :style="setting.style">
			<slot></slot>
		</view>
	</vi-popup>
</template>

<script>
	// 本组件是vi-popup的方案定制版本，用于立即成型，快速调用，省去重复配置参数
	// 方案定义位于options.js
	import options from "./options.js"
	export default{
		name:"commonPopup",
		props:{
			mode:{
				type:[String,null],
				default:""
			},
			//特殊设置覆盖
			options:{
				type:[Object,null],
				default:()=>({})
			},
			//窗口偏移
			shift:{
				type:[Object,null],
				default:()=>({})
			}
		},
		data(){
			return {
				
			}
		},
		computed:{
			setting(){
				let name = this.mode || Object.keys(options)[0],
					res = Object.assign({}, options[name]);
				if(this.$api.isObject(this.options)){
					Object.assign(res, this.options)
				}
				return res
			}
		},
		methods:{
			open(dataSet){
				this.$refs.popup.open();
			},
			close(){
				this.$refs.popup.close();
			},
			onChange(e){
				this.$emit("change", e)
			},
			onClosed(e){
				this.$emit("closed", e)
			},
			onOpened(e){
				this.$emit("opened", e)
			},
			onMaskClick(){
				this.$emit("maskClick")
			}
		}
	}
</script>

<style lang="scss">

</style>